Left

data class Left<out L>(val value: L) : Either<L, Nothing>

Constructors

Link copied to clipboard
fun <out L> Left(value: L)

Functions

Link copied to clipboard
inline fun all(predicate: (Nothing) -> Boolean): Boolean

Returns the result of applying the predicate to the value if this is Right or true if this is Left.

Link copied to clipboard
inline fun any(predicate: (Nothing) -> Boolean): Boolean

Returns the result of applying the predicate to the value if this is Right or false if this is Left.

Link copied to clipboard
open operator override fun contains(element: Any): Boolean

Returns true if the element is equal to the value of this Either, or false otherwise.

Link copied to clipboard
inline fun filter(predicate: (Nothing) -> Boolean): Either<L, Nothing>?

Returns the same Right if the predicate is satisfied for the value. Otherwise returns null.

Link copied to clipboard
inline fun <T> filterIsInstance(): Either<L, T>?

Returns the same Right casted to type T if it is T. Otherwise returns null.

Link copied to clipboard
inline fun <T> filterIsInstanceToOption(): Option<Either<L, T>>

Returns Some containing the same Right casted to type T if it is T. Otherwise returns None.

Link copied to clipboard
inline fun filterNot(predicate: (Nothing) -> Boolean): Either<L, Nothing>?

Returns the same Right if the predicate is not satisfied for the value. Otherwise returns null.

Link copied to clipboard
inline fun filterNotToOption(predicate: (Nothing) -> Boolean): Option<Either<L, Nothing>>

Returns Some containing the same Right if the predicate is not satisfied for the value. Otherwise returns None.

Link copied to clipboard
inline fun filterToOption(predicate: (Nothing) -> Boolean): Option<Either<L, Nothing>>

Returns Some containing the same Right if the predicate is satisfied for the value. Otherwise returns None.

Link copied to clipboard
inline fun <T> fold(leftTransform: (L) -> T, rightTransform: (Nothing) -> T): T

Transforms Left with leftTransform or Right with rightTransform.

Link copied to clipboard
inline fun forEach(action: (Nothing) -> Unit)

Runs action if this is a Right. Returns Unit without any action if this is a Left.

Link copied to clipboard
fun get(): Nothing

Gets value of this Right.

Link copied to clipboard
fun getOrNull(): Nothing?

Gets value of this Right or null if this is Left.

Link copied to clipboard
inline fun <T> map(transform: (Nothing) -> T): Either<L, T>

Maps value of this Right using transform.

Link copied to clipboard
inline fun none(predicate: (Nothing) -> Boolean): Boolean

Returns false if the predicate is met by the value if this is Right or true otherwise.

Link copied to clipboard
open override fun swap(): Either<Nothing, L>

Swaps Left to Right and Right to Left.

Link copied to clipboard
fun toOption(): Option<Nothing>

Returns a Some containing the Right value if it exists, or a None if this is a Left.

Properties

Link copied to clipboard
open override val isLeft: Boolean

Returns true if this is a Left or false if this is Right.

Link copied to clipboard
open override val isRight: Boolean

Returns true if this is a Right or false if this is Left.

Link copied to clipboard
val left: LeftProjection<L, Nothing>

Projects Either as Left.

Link copied to clipboard
val right: RightProjection<L, Nothing>

Projects Either as Right.

Link copied to clipboard
val value: L